/*
 * @Author: your name
 * @Date: 2020-03-21 23:26:07
 * @LastEditTime: 2020-04-28 00:34:43
 * @LastEditors: your name
 * @Description: In User Settings Edit
 * @FilePath: \museweb\src\views\musePage\mixins\tableMixin.js
 */
export default {
  data () {
    return {
      paging: {
        page: 1,
        total: 0,
        pageSize: 10,
        pageSizeAry: [10, 50, 100],
      },
      selectedData: [],
      tableData: []
    }
  },
  methods: {
    wrapConfirm(typeIndex, autoText = '') {
      let tempText = ''
      switch (typeIndex) {
        case 0:
          tempText = '此操作将永久删除数据, 是否继续?'
          break
        case 1:
          tempText = '此操作将永久删除选中数据, 是否继续?'
          break
        case 2:
          tempText = '此操作将上线该条记录, 是否继续?'
          break
        case 3:
          tempText = '此操作将下线该条记录, 是否继续?'
          break
        case 4:
          tempText = '此操作将删除该条记录, 是否继续?'
          break
        default:
          tempText = autoText
      }
      return this.$confirm(tempText, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
    },
    handleSelectionChange(value) {
      this.selectedData = value
      console.log('selected change', this.selectedData)
    },
    handleSizeChange(value) {
      this.getTableData(value, 'pageSize')
    },
    handleCurrentChange(value) {
      this.getTableData(value, 'page')
    },
    // 过滤搜索
    filterSearch(refName) {
      this.$refs[refName].validate((valid) => {
        if (valid) {
          this.getTableData()
        } else {
          return false;
        }
      });
    },
    // 重置表单
    resetForm(refName) {
      this.form = {}
      this.getTableData()
    },
    resetFormByFilter(refName) {
      this.form = {}
      this.getTableData()
    }
  }
}
